//
// Created by Administrator on 2020/12/29 0029.
//

#include "static_field_access.h"
#include <jni.h>
#include <string.h>
#include <stdio.h>

JNIEXPORT void  JNICALL Java_com_yangyongfeng_JNI_1library_StaticFieldAccess_accessStaticField(JNIEnv *env,jobject obj)
{
    jfieldID  fid;
    jint si;
    char type ;
    //get reference to obj's class
    jclass  cls = (*env).GetObjectClass(obj);
    if ( cls == NULL )
        return;
    printf("Run in C:\n");

    //look for the static field si in cls
    //fid = (*env).GetStaticFieldID(cls,"my_sex","C");
    fid = (*env).GetStaticFieldID(cls,"my_sex","C");
    if (fid == NULL){
        return;
    }
    type = (*env).GetStaticCharField(cls,fid);
    printf("StaticFieldIntField.type = %d\n",type);
    (*env).SetStaticCharField(cls,fid,'F');


}